package com.molichuxing.framework.utils;

import java.util.Date;
import java.util.Iterator;
import java.util.Map;
import java.util.UUID;

import io.jsonwebtoken.JwtBuilder;
import io.jsonwebtoken.Jwts;
import io.jsonwebtoken.SignatureAlgorithm;

/**
 * @ Author ：zhouzc. 
 * @ Date ：Created in 13:44 2019/3/21 
 * @ Description： @
 * Modified By：
 * 
 * @Version: $
 */
public class GenerateToken {

	private static String creteToken() {

		return UUID.randomUUID().toString().replace("-", "");
	}

	/**
	 * 生成token
	 * 
	 * @param map
	 * @param salt
	 * @param expirationTime
	 * @return
	 */
	public static String createToken(Map<String, String> map, String salt, Long expirationTime) {
		JwtBuilder jwtBuilder = Jwts.builder().signWith(SignatureAlgorithm.HS256, salt).setIssuedAt(new Date())
				.setExpiration(new Date(System.currentTimeMillis() + expirationTime));
		Iterator var4 = map.entrySet().iterator();

		while (var4.hasNext()) {
			Map.Entry<String, String> entry = (Map.Entry) var4.next();
			jwtBuilder.claim(entry.getKey(), entry.getValue());
		}

		return jwtBuilder.compact();
	}

}
